<template>
  <div class="list-content">
    <div class="list-header clearfix">
      <div class="list-header-tit fl">信件</div>
      <div class="list-close fr" style="font-size: 16px;background:#ffffff;" > 
        <span @click="backHome">返回首页：</span>
        <img src="../../assets/image/backhome.png" style="width:24px;height:24px;"  @click="backHome">
        &nbsp;
        <span @click="jumpMailDetail">我要写信：</span>
        <img src="../../assets/image/jump_to.png" style="width:22px;height:22px;" @click="jumpMailDetail">
        <!--
        <i @click="backHome" class="list-close el-icon-circle-close"></i>
        -->
      </div>
    </div>
    <div class="list-table">
      <div class="home-table">
        <!--
        <table class="app-table">
          <thead>
            <th>编号</th>
            <th>标题</th>
            <th>写信日期</th>
            <th>状态</th>
          </thead>
          <tbody v-if="list.length">
            <tr v-for="item in list" :key="item.id"  >
              <td>{{ item.serialNumber }}</td>
              <td style="width:60%">{{ item.title | filterWords(21)   }}</td>
              <td>{{ item.createTime }}</td>
              <td>{{ item.status }}</td>
            </tr>
          </tbody>
          <tbody v-if="!list.length">
            <tr>
              <td>暂无数据</td>
              <td>暂无数据</td>
              <td>暂无数据</td>
              <td>暂无数据</td>
            </tr>
          </tbody>
        </table>
        -->
       <iframe
        id="data_mail"
        height='400'
        src="http://www.sc.gov.cn/10462/c101435/zwfw_szxx.shtml"
        width="100%" frameborder="0"
        @load="ch"
      ></iframe>
        
      </div>
    </div>
    <!--
    <div class="page-wrap">
      <el-pagination
        background
        :current-page="pageIndex"
        :page-size="pageSize"
        @current-change="pageChange"
        layout="prev, pager, next,jumper"
        :total="Number(total)"
      >
      </el-pagination>
    </div>
    -->
  </div>
</template>

<script>
import { getMailList, getUserInfo } from '@/api'
export default {
  data() {
    return {
      list:[],
      pageIndex:1,
      pageSize:10,
      total:0,
    };
  },
  computed:{
    getUser(){
      return this.$store.state.user;
    }
  },
  mounted(){
    this.getData();
  },
  methods:{
    backHome(){
      this.$router.push({ name:'home' });
    },

    jumpMailDetail(){
       window.open("http://rzsc.sczwfw.gov.cn/sso.action?providerId=195004716&target=http://www.sc.gov.cn/scszmail/complaint/index","_blank");
    },

    pageChange(num){
      this.pageIndex = num;
      this.getList();
    },
    getData(){ // 保证有userid
      if(this.getUser.id){
        this.getList();
      }else{
        let url = '/sys/sysMember/getMember';
        getUserInfo(url).then(res=>{
          if(res.data.code == 200){
            this.$store.commit('setUserinfo',{
              id:res.data.data.id,
              name:res.data.data.loginName,
              mobile:res.data.data.mobile,
            })
            this.getList();
          }
        })
      }
    },
    getList(){
      let url = '/sys/sysMember/getMailList';
      let params = {
        phone:this.getUser.mobile,
        pageNum: this.pageIndex,
        pageSize: this.pageSize,
      }
      getMailList(url,params).then(res=>{
        if(res.data.status == 'success'){
          this.list = res.data.data.rows || [];
          this.total = res.data.data.total || 0;
        }else{
          this.list = [];
          this.total =0;
        }
      })




    },
    enterMailDetail(item){

      
      if(process.env.NODE_ENV === "production"){
        window.open("/usercenter/mailDetail?id=" + item.id, "_blank")
      }else {
        window.open("/mailDetail?id=" + item.id, "_blank")
      }

    }

    
  }
};
</script>

<style lang="scss" scoped>

</style>
